@echo off
REM 设置命令行编码为 UTF-8
chcp 65001

REM 定义源文件和目标目录
set SOURCE_FILE=D:\scraping\pythonProject\mate\clean\jiani\data_claen_2.py
set TARGET_DIR=D:\scraping\pythonProject\target\clean_data_2

REM 确保目标目录存在
if not exist %TARGET_DIR% (
    mkdir %TARGET_DIR%
)

REM 设置 PYTHONPATH，确保所有模块路径被找到
set PYTHONPATH=%PYTHONPATH%;D:\scraping\pythonProject\h3yun\service;D:\scraping\pythonProject\h3yun\utils;D:\scraping\pythonProject\config

REM 设置 PYTHONIOENCODING
set PYTHONIOENCODING=utf-8

REM 使用 PyInstaller 打包
pyinstaller --noconsole --onefile ^
    --distpath %TARGET_DIR% ^
    --workpath %TARGET_DIR%\build ^
    --specpath %TARGET_DIR%\spec ^
    --add-data "D:\scraping\pythonProject\mate\clean\jiani\template\月度流向数据_专员分配_分科_模板.xlsx;template" ^
    --paths=D:\scraping\pythonProject\h3yun\service ^
    --paths=D:\scraping\pythonProject\h3yun\utils ^
    --paths=D:\scraping\pythonProject\config ^
    --hidden-import openpyxl ^
    --collect-submodules openpyxl ^
    %SOURCE_FILE%

REM 打包完成提示
echo.
echo ============================
echo 打包完成！
echo 可执行文件位置：%TARGET_DIR%
echo ============================
pause
